class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        i, j, subtring = 0, 1, ""
        while j < len(s):
            if s[i:j].find(s[j]) > -1:
                if len(subtring) < j - i + 1:
                    subtring = s[i:j]
                i = i + 1
            else:
                j += 1
        else:
            if len(subtring) < j - i + 1:
                subtring = s[i:j]
        return len(subtring)


if __name__ == "__main__":
    text = "sdshsgdj"
    print("text:{0}, longest substring length:{1}".format(
        text, Solution().lengthOfLongestSubstring(text)))
